<template>
  <div class="shop">
    <div class="swiper">
      <template>
        <el-carousel height="372px" :interval="5000" arrow="always">
          <el-carousel-item v-for="swiper in swipers" :key="swiper.id">
            <el-image :src="api + swiper.image"></el-image>
          </el-carousel-item>
        </el-carousel>
      </template>
    </div>
    <div class="content">
      <ul>
        <li v-for="stop in stops" :key="stop.id">
          <div class="image" @click="jumpStoryCont(stop.id)"><img :src="api + stop.image" alt=""></div>
          <div class="text">
            <h3 @click="jumpStoryCont(stop.id)">{{stop.title}}</h3>
            <p>{{stop.content}}</p>
          </div>
        </li>
      </ul>
      <!-- 分页 -->
      <!-- <div class="block">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="50">
        </el-pagination>
      </div> -->
    </div>
  </div>
</template>

<script>
import { getShopSwiper, getShop } from '../../api/shop'

export default {
  data () {
    return {
      swipers: '',
      stops: '',
      api: 'http://47.96.89.247:8080/qf_hotel'
    }
  },
  created () {
    getShopSwiper().then(res => {
      this.swipers = res.data
    }).catch(err => console.log('数据加载异常', err))
    getShop().then(res => {
      this.stops = res.data
    }).catch(err => console.log('故事数据加载异常', err))
  },
  methods: {
    jumpStoryCont (id) {
      this.$router.push({
        path: 'content',
        query: {
          id,
          name: 'shop'
        }
      })
    }
  }
}
</script>

<style lang="scss" >
body{
  background: #f4f4f4;
}
.shop{
  .swiper{
    .el-carousel__arrow{
      width: 60px;
      height: 60px;
    }
    .el-icon-arrow-left, .el-icon-arrow-right{
      font-size: 25px;
    }
    .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
    }
    .el-carousel__item:nth-child(2n) {
      background-color: #99a9bf;
    }
    .el-carousel__item:nth-child(2n+1) {
      background-color: #d3dce6;
    }
  }
  .content{
    padding-top: 10px;
    ul{
      width: 75%;
      margin: 0 auto;
      li{
        height: 50px;
        padding: 20px;
        margin-bottom: 10px;
        background: #fff;
        border: 1px solid #e8e8e8;
        .image{
          width: 75px;
          height: 100%;
          padding-right: 35px;
          display: inline-block;
          cursor: pointer;
          img{
            width: 100%;
            height: 100%;
          }
        }
        .text{
          display: inline-block;
          height: 100%;
          h3{
            display: block;
            font-size: 18px;
            padding-bottom: 10px;
            line-height: 24px;
            cursor: pointer;
            a{
              display: inline-block;
              color: #000000;
            }
          }
          p{
            width: 600px;
            color: #666666;
            line-height: 24px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
    .block{
      width: 25%;
      margin: 0 auto;
      .el-pagination{
        display: flex;
        align-items: center;
        li{
          line-height: 12px;
        }
      }
    }
  }
}
</style>
